
AddCSLuaFile( "shared.lua" )
SWEP.Weight				= 5
SWEP.AutoSwitchTo		= false
SWEP.AutoSwitchFrom		= false

SWEP.DrawAmmo			= true
SWEP.DrawCrosshair		= true
SWEP.ViewModelFOV		= 60
SWEP.ViewModelFlip		= false
SWEP.CSMuzzleFlashes	= true

SWEP.Author						= "blankthemuffin / -Anders-"
SWEP.Contact					= "don't even try"
SWEP.Purpose					= "None really"
SWEP.Instructions				= "maybe I need shit in here"

SWEP.ViewModel					= "models/weapons/v_superphyscannon.mdl"
SWEP.WorldModel					= "models/weapons/w_physics.mdl"

SWEP.Spawnable					= false
SWEP.AdminSpawnable				= false

SWEP.Primary.MaxDamage			= 100
SWEP.Primary.ClipSize			= 100
SWEP.Primary.DefaultClip		= 100
SWEP.Primary.Automatic			= false
SWEP.Primary.Ammo				= "SniperRound"

SWEP.Secondary.ClipSize			= -1
SWEP.Secondary.DefaultClip		= -1
SWEP.Secondary.Automatic		= false
SWEP.Secondary.Ammo				= "none"


--[[-------------------------------------------------------------------------------------------------
 Think, 
 called every think.
-------------------------------------------------------------------------------------------------]]--
function SWEP:Think()
	if self:Clip1() < 100 then 
		self:SetClip1( self:Clip1() + 1 )
	end
end

--[[-------------------------------------------------------------------------------------------------
 Can Primary Attack, 
 called when we want to shoot.
-------------------------------------------------------------------------------------------------]]--
function SWEP:CanPrimaryAttack()
	if self:Clip1() >= 100 then
		return true
	else
		return false
	end
end

--[[-------------------------------------------------------------------------------------------------
 PrimaryAttack 
 Called when we shoot. :D
-------------------------------------------------------------------------------------------------]]--
function SWEP:PrimaryAttack()
	if ( !self:CanPrimaryAttack() ) then return end
	
	local damage = self.Primary.MaxDamage
	
	local Trace = util.QuickTrace( self.Owner:GetShootPos(), self.Owner:GetAimVector() * 10000, { self.Owner } ) 

	local pos1 = self.Owner:GetPos()
	local pos2 = Trace.HitPos
	damage = math.Clamp( damage - ( (pos1 - pos2):Length() * 0.05 ), 1, 100 )
	
	local bullet = {}
	bullet.Num 		= 1
	bullet.Src 		= self.Owner:GetShootPos()			
	bullet.Dir 		= self.Owner:GetAimVector()			
	bullet.Spread 	= 0
	bullet.Tracer	= 0
	bullet.TracerName = "Tracer"
	bullet.Force	= 50
	bullet.Damage	= damage
	
	self.Owner:FireBullets( bullet )
	
	self:SetClip1( self:Clip1() - 100 )
	self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) 		// View model animation
	self.Owner:MuzzleFlash()								// Crappy muzzle light
	self.Owner:SetAnimation( PLAYER_ATTACK1 )				// 3rd Person Animation	
	
	local effectdata = EffectData()
	effectdata:SetStart( self.Owner:GetShootPos() )
	effectdata:SetOrigin( pos2 )
	effectdata:SetAttachment( 1 )
	effectdata:SetEntity( self.Weapon )
	util.Effect( "seek_beam", effectdata )
end

--[[-------------------------------------------------------------------------------------------------
 CanSecondaryAttack, 
-------------------------------------------------------------------------------------------------]]--
function SWEP:CanSecondaryAttack()
	return true
end

--[[-------------------------------------------------------------------------------------------------
 SecondaryAttack, 
-------------------------------------------------------------------------------------------------]]--
function SWEP:SecondaryAttack()
	-- Do something interesting in here too.
end
